package rad.framework.mda.generator.template.main.java.seam;

import java.util.*;
import org.eclipse.uml2.uml.*;
import rad.framework.mda.generator.util.*;
import org.eclipse.emf.codegen.util.*;

public class Controller
{
  protected static String nl;
  public static synchronized Controller create(String lineSeparator)
  {
    nl = lineSeparator;
    Controller result = new Controller();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = "/*" + NL + " * ============================================================================" + NL + " *                   GNU Lesser General Public License" + NL + " * ============================================================================" + NL + " */" + NL + "package ";
  protected final String TEXT_3 = ";" + NL;
  protected final String TEXT_4 = NL + NL + "/**" + NL + " * ";
  protected final String TEXT_5 = NL + " *" + NL + " * @author ";
  protected final String TEXT_6 = NL + " * @version 1.0" + NL + " * @generated" + NL + " */" + NL + "@Local" + NL + "public interface ";
  protected final String TEXT_7 = "Controller extends AbstractController{";
  protected final String TEXT_8 = NL + NL + "    /**" + NL + "     * ";
  protected final String TEXT_9 = NL + "     * @generated " + NL + "     */" + NL + "    String ";
  protected final String TEXT_10 = "();" + NL + "" + NL + "    /** @generated */" + NL + "    boolean is";
  protected final String TEXT_11 = "Rendered();" + NL + "" + NL + "    /** @generated */" + NL + "    boolean is";
  protected final String TEXT_12 = "Disabled();";
  protected final String TEXT_13 = NL + "}";
  protected final String TEXT_14 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    Region region = (Region) argument;
    stringBuffer.append(TEXT_1);
    stringBuffer.append(TEXT_2);
    stringBuffer.append(NameHelper.getQualifiedName(region.getStateMachine()));
    stringBuffer.append(TEXT_3);
    ImportManager importManager = ImportHelper.makeImportManager("");
    ImportHelper.addImport(region);
    importManager.addImport("javax.ejb.Local");
    importManager.addImport("rad.framework.seam.AbstractController");
    
StringBuffer importStringBuffer = stringBuffer;
int importInsertionPoint = stringBuffer.length();
importManager.addCompilationUnitImports(stringBuffer.toString());

    stringBuffer.append(TEXT_4);
    stringBuffer.append(TypeHelper.getDocumentation(region));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(System.getProperty("user.name"));
    stringBuffer.append(TEXT_6);
    stringBuffer.append(NameHelper.getCapName(region));
    stringBuffer.append(TEXT_7);
    for (Iterator<State> j=JsfHelper.getPages(region); j.hasNext();) { State state = (State)j.next();
    for (Iterator<Transition> k=state.getOutgoings().iterator(); k.hasNext();) { Transition t = (Transition)k.next();
    stringBuffer.append(TEXT_8);
    stringBuffer.append(TypeHelper.getDocumentation(t));
    stringBuffer.append(TEXT_9);
    stringBuffer.append(NameHelper.removeSpaces(NameHelper.uncapSafeName(t.getSource()) + NameHelper.getCapName(t)));
    stringBuffer.append(TEXT_10);
    stringBuffer.append(NameHelper.removeSpaces(NameHelper.getCapName(t.getSource()) + NameHelper.getCapName(t)));
    stringBuffer.append(TEXT_11);
    stringBuffer.append(NameHelper.removeSpaces(NameHelper.getCapName(t.getSource()) + NameHelper.getCapName(t)));
    stringBuffer.append(TEXT_12);
    }}
    stringBuffer.append(TEXT_13);
    importStringBuffer.insert(importInsertionPoint, importManager.computeSortedImports());
    stringBuffer.append(TEXT_14);
    return stringBuffer.toString();
  }
}
